package com.bosssoft.setp.model.business.aliance;

import xyz.erupt.annotation.Erupt;
import xyz.erupt.annotation.EruptField;
import xyz.erupt.annotation.sub_erupt.Power;
import xyz.erupt.annotation.sub_erupt.Tree;
import xyz.erupt.annotation.sub_field.Edit;
import xyz.erupt.annotation.sub_field.EditType;
import xyz.erupt.annotation.sub_field.View;
import xyz.erupt.annotation.sub_field.sub_edit.ReferenceTreeType;
import xyz.erupt.jpa.model.BaseModel;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * 区域下拉框的节点类
 *
 * @author lin-gaoying
 * @version 1.0
 * @since 1.0
 */
@Entity
@Table(name = "setp_aliance_business_area")
@Erupt(
        name = "树",
        tree = @Tree(pid = "parent.id" ,expandLevel = 1),
        power = @Power(add = true, delete = true,
                edit = true, query = true,
                importable = false, export = false)
)
public class AlianceBusinessArea extends BaseModel {

    @EruptField(
            views = @View(title = "名称"),
            edit = @Edit(title = "名称")
    )
    private String name;

    @ManyToOne
    @JoinColumn(name = "parent")
    @EruptField(
            edit = @Edit(
                    title = "上级树节点",
                    type = EditType.REFERENCE_TREE,
                    referenceTreeType = @ReferenceTreeType(pid = "parent.id",expandLevel = 1)
            )
    )
    private AlianceBusinessArea parent;

}